﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IHISCETeim.Library;
namespace IHISCETeim.Web.MachineSys
{
    #region 枚举
    /// <summary>
    /// 起动前点检
    /// </summary>
    public enum QTQDJEnum
    {     
        发动机周围确认,
        油压件确认,
        规格确认,
        油燃料RAG冷却液,
        液压油配管油漏泄,
        /// <summary>
        /// 135增加
        /// </summary>
        回转马达齿轮油检查,
        /// <summary>
        /// 100nsgb3增加
        /// </summary>
        发动机机油盖确认
    }

    /// <summary>
    /// 性能检查
    /// </summary>
    public enum XRJCEnum
    { 
        铁履H前10m,
        铁履H后10m,
        铁履L前10m,
        铁履L后10m,
        履带板宽度左,
        履带板宽度右,
        涨紧油缸单向阀位置左,
        涨紧油缸单向阀位置右,
        履带厂商,
        油铲斗CYL伸,
        油铲斗CYL缩,
        油小臂CYL伸,
        油小臂CYL缩,
        油大臂CYL伸,
        油大臂CYL缩,

        行走曲进10ML前,
        行走曲进10ML后,
        行走曲进10MH前,
        行走曲进10MH后,

        防冻液混合率49时,
        防冻液混合率41时,
        防冻液混合率30时,

        履带张力左,
        履带张力右,

        回转卡块偏移量,
        回转速度转2次左,
        回转速度转2次右,
        回转制动器90回转左,
        回转制动器90回转右,

        回转马达15倾斜地左,
        回转马达15倾斜地右,
        大臂CYL缩,
        小臂CYL伸,
        铲斗CYL伸,
        整体下降,
        推土板CYLL伸,
        推土板CYLR伸,
        行走马达15倾斜地左,
        行走马达15倾斜地右,

        推土板水平度,
        铲斗水平度
    }

    /// <summary>
    /// 工作确认
    /// </summary>
    public enum GZQREnum
    { 
        行走时的异音异常,
        回转时的异音异常,
        ATT操作时的异音异常,
        手柄制动是否有效,
        发动机转速是否稳定正常,
        行走独立大臂操作H,
        行走独立大臂操作L,
        行走独立小臂操作H,
        行走独立小臂操作L,
        行走独立铲斗操作H,
        行走独立铲斗操作L,
        复合动作,
        柴油,
        预备配管,
        阀无冲击现象,
        回转刹车油管连接确认

    }

    /// <summary>
    /// 性能检查储存信息
    /// </summary>
    public class XRJCItem
    {
        public string Key { get; set; }

        public string Value { get; set; }

        public string NGValue { get; set; }
    }
    #endregion
    public static class CompleteCheckXMLHelper
    {
        private static SerializableDictionary<string,bool> _QTJDJXMLDict=null;
        /// <summary>
        /// 启动前点检所有的项
        /// </summary>
        private static SerializableDictionary<string, bool> QTJDJXMLDict
        {
            get
            {
                if(_QTJDJXMLDict==null)
                {
                    _QTJDJXMLDict = new SerializableDictionary<string, bool>();
                    string[] strItems = Enum.GetNames(typeof(QTQDJEnum));
                    foreach (string str in strItems)
                    {
                        _QTJDJXMLDict.Add(str,false);
                    }
                }
                return _QTJDJXMLDict;
            }
        }

        private static SerializableDictionary<string, XRJCItem> _XRJCDict = null;
        /// <summary>
        /// 性能检查所有的项
        /// </summary>
        public static SerializableDictionary<string, XRJCItem> XRJCDict
        {
            get
            {
                if(_XRJCDict==null)
                {
                    _XRJCDict = new SerializableDictionary<string, XRJCItem>();
                    string[] strItems = Enum.GetNames(typeof(XRJCEnum));
                    foreach (string str in strItems)
                    {
                        _XRJCDict.Add(str,new XRJCItem());
                    }
                }
                return _XRJCDict;
            }
        }

        private static SerializableDictionary<string, bool> _GZQRDict = null;
        /// <summary>
        /// 工作确认所有的项
        /// </summary>
        public static SerializableDictionary<string, bool> GZQRDict
        {
            get
            {
                if(_GZQRDict==null)
                {
                    _GZQRDict = new SerializableDictionary<string, bool>();
                    string[] strItems = Enum.GetNames(typeof(GZQREnum));
                    foreach (string str in strItems)
                    {
                        _GZQRDict.Add(str,false);
                    }
                }
                return _GZQRDict;
            }
        }
        /// <summary>
        /// 获取当前请求中的工作确认项的XML表示字符串
        /// </summary>
        /// <returns></returns>
        public static string GetGZQRXMLStr()
        {

            SerializableDictionary<string, bool> tempdic = new SerializableDictionary<string, bool>(GZQRDict);

            foreach (var x in GZQRDict)
            {
                tempdic[x.Key] = HttpContext.Current.Request.GetRequestValue<bool>(x.Key);
            }
            return XmlSerializerHelper.Serialize(tempdic);
            //HttpContext.Current.Request
        }
        /// <summary>
        /// 获取当前请求中的性能检查的XML表示字符串
        /// </summary>
        /// <returns></returns>
        public static string GetXRJCXMLStr()
        {

            SerializableDictionary<string, XRJCItem> tempdic = new SerializableDictionary<string, XRJCItem>(XRJCDict);

            foreach (var x in XRJCDict)
            {
                XRJCItem tempitem = new XRJCItem();
                tempitem.Key = x.Key;
                tempitem.Value = HttpContext.Current.Request.GetRequestValue<string>(x.Key, true, "");
                tempitem.NGValue = HttpContext.Current.Request.GetRequestValue<string>("NG_"+x.Key,true,"");
                tempdic[x.Key] = tempitem;

                //tempdic[x.Key] = HttpContext.Current.Request.GetRequestValue<float>(x.Key);
            }
            return XmlSerializerHelper.Serialize(tempdic);
            //HttpContext.Current.Request
        }

        /// <summary>
        /// 获取当前请求中的性能检查的XML表示字符串
        /// </summary>
        /// <returns></returns>
        public static string GetQTJDJXMLStr()
        {

            SerializableDictionary<string, bool> tempdic = new SerializableDictionary<string, bool>(QTJDJXMLDict);

            foreach (var x in QTJDJXMLDict)
            {
                tempdic[x.Key] = HttpContext.Current.Request.GetRequestValue<bool>(x.Key);
            }
            return XmlSerializerHelper.Serialize(tempdic);
            //HttpContext.Current.Request
           
        }
    }
}